module("class",package.seeall)
funcstoreindex="func"
subfuncsstoreindex="_subfuncs"
tablestoreindex="table"
calltable=function()

end

classitemset=function(table,key,val)
	if type(val)=="function" then
		newsubfunc(table,key,val)
	else
		rawset(table,key,val)
	end
end

newsubfunc=function(table,funcname,func,)
	rawset(table,subfuncsstoreindex,rawget(table,subfuncsstoreindex) or {})
	rawset(rawget(talbe,subfuncsstoreindex),funcname,func)
end

callsubfunc=function(table,...)
	rawget(table,funcstoreindex)(rawget(table,tablestoreindex),...)
end

bindsubfunc=function(table,class,funcname)
	local t={}
	t[funcstoreindex]=rawget(rawget(class,subfuncsstoreindex),funcname)
	t[tablestoreindex]=table
	t.__call=callsubfunc
	rawset(table,funcname,t)
end

bindclass=function(table,class)
	if type(table)=="string" then table=_G[table] end
	if type(class)=="string" then table=_G[class] end
	local i,v 
	for i,v inpairs(class[subfuncsstoreindex]) do
		bindsubfunc(table,class,i)
	end
end

defclassfunc=function(class)
	if type(class)=="string" then table=_G[class] end

	setfenv(2,class)
end